from Tkinter import *
from tkFileDialog import askopenfilename
from os import getcwd

class Parcourir(Frame):
    'Search for the file and get the filename'
    def __init__(self, master = None, command = None, **kw):
        Frame.__init__(self, master, **kw)

        self.chemin = StringVar()
        self.chemin.set(getcwd())
        
        self.command = command

        self.entree_chemin = Entry(self, text = self.chemin, width = 70)
        self.entree_chemin.grid(row = 2, column = 1,padx = 10, pady = 5)

        self.bouton = Button(self, text = "Browse", command = self.parcours)
        self.bouton.grid(row = 2, column = 2, padx = 5, pady = 5)


    def parcours(self):
        chemin = askopenfilename()
        if chemin != '':
            self.chemin.set(chemin)
            if self.command != None:
                self.command()
                
    def get(self):
        return str(self.chemin.get())

